interface Card {
    suit:string,
    card:number
}

interface Deck {
    suits:string[],
    cards:Array<number>,
    // 手动传入了this 对象 并且类型为Deck
    createCardPicker(this:Deck):()=>Card
}

let deck:Deck = {
    suits:['1','2'],
    cards:Array[52],
    createCardPicker:function(this){
        return ()=>{

            let pickedCard = Math.floor(Math.random() * 52);
            let pickedSuit = Math.floor(pickedCard / 13);

            return {suit: this.suits[pickedSuit], card: pickedCard % 13};
        }
    }
}

let cardPicker = deck.createCardPicker();
let pickedCard = cardPicker();

alert("card: " + pickedCard.card + " of " + pickedCard.suit);